package gui.catalogues.persons;

import gui.commons.CopUtils;

import java.io.File;

import javax.swing.filechooser.FileFilter;


public class PersonFileFilter extends FileFilter {
	/*
	 * name and extension variables
	 * */
	private String name, ext;
	
	public boolean accept(File arg) {
		
		// before comparing anything, I'll let directories pass
		if(arg.isDirectory()) return true;
		
		name = arg.getName();
		ext = CopUtils.getFileExtension(name);
		
		// if the getFileExtension fails
		if(ext == null) return false;
		// if the extension is what I'm looking for, i.e. the "per" extension
		if(ext.equals("per")) return true;
		
		// default
		return false;
	}
	
	public String getDescription() {
		return "Person db files (*.per)";
	}
}
